package com.yihen.controller;

import com.yihen.dto.Result;
import com.yihen.mappers.PatientMapper;
import com.yihen.pojo.Patient;
import com.yihen.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/patients")
public class PatientController {

    @Autowired
    private PatientService patientService;

    @GetMapping("/all/patients/{id}")
    public Result getAllPatientsByIds(@PathVariable long id) {
        return patientService.getAllPatientByDoctorId(id);
    }

    // 查询所有患者信息
    @GetMapping("/all/")
    public Result getAllPatients() {
        return patientService.getAllPatients();
    }

    // 根据id删除患者
    @GetMapping("/delete/{id}")
    public Result deletePatientById(@PathVariable long id) {
        return patientService.deletePatientById(id);
    }

    // 添加患者信息
    @PostMapping("/add")
    public Result addPatient(@RequestBody Patient patient) {
        return patientService.addPatient(patient);
    }

    // 条件查询患者信息
    @PostMapping("/get/condition")
    public Result getPatientsByCondition(@RequestBody Patient patient) {
        return patientService.getPatientByCondition(patient);
    }

    // 根据id查询患者信息
    @GetMapping("/get/id/{id}")
    public Result getPatientById(@PathVariable long id) {
        return patientService.getPatientById(id);
    }

    // 根据id修改患者信息
    @PostMapping("/update")
    public Result updatePatient(@RequestBody Patient patient) {
        return patientService.updatePatient(patient);
    }

    // 根据ids批量删除患者信息
    @PostMapping("/delete/ids")
    public Result deleteDoctorsByIds(@RequestBody List<Long> ids) {
        return patientService.deletePatientByIds(ids);
    }
}
